/* Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/*/
$(document).ready(function() {
  // Initialize the jQuery File Upload widget:
  $('#fileupload').fileupload();
  $('#fileupload').fileupload('option', {
    maxFileSize: 5000000,
    acceptFileTypes: /(\.|\/)(gif|jpe?g|png)$/i,
    process: [
    {
      action: 'load',
      fileTypes: /^image\/(gif|jpe?g|png)$/i,
      maxFileSize: 20000000          
    },
    {
      action: 'resize',
      maxWidth: 1440,
      maxHeight: 900
    },
    {
      action: 'save'
    }
    ]
  });
    // Load existing files:
    /*
    $.getJSON($('#fileupload').prop('action'), function (files) {
      var fu = $('#fileupload').data('fileupload'), 
      template;
      if ( undefined != fu ) {
        fu._adjustMaxNumberOfFiles(-files.length);
        template = fu._renderDownload(files)
        .appendTo($('#fileupload .files'));
        // Force reflow:
        fu._reflow = fu._transition && template.length &&
        template[0].offsetWidth;
        template.addClass('in');
        $('#loading').remove();
      }
    });*/

  $('#wizard').smartWizard({
    onLeaveStep:leaveAStepCallback,
    onFinish:finishCallback
  });

  //$('#wizard').smartWizard("fixHeight");
});

function leaveAStepCallback(obj,context) {
  return validateSteps(context.fromStep);
}

function validateSteps(stepNumber) {
  if (stepNumber == 1) {
    if ( $("input[name='admin_umbrella[category]']:checked").length == 0 ) {
      return false;
    }
    return true;
  } else if ( stepNumber == 2) {
    
  }
  return true;
}

function finishCallback(objs,context) {
  return false;
}
